<?php 
class ControllerMessageEthos extends Controller {
	
	public function all(){
		$this->language->load('message/ethos');
		$this->load->model('message/ethos');
		$this->data['breadcrumbs'] = array();

		$this->data['breadcrumbs'][] = array(
			'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home'),
			'separator' => false
		);

		if (isset($this->request->get['ethos_id'])) {
			$ethos_id = (int)$this->request->get['ethos_id'];
		} else {
			$ethos_id = 0;
		}
		$this->data['ethosInfos'] = array();
		$this->load->model('tool/image');
		$policeInfos = $this->model_message_ethos->getAllEthoss();
			$this->document->setTitle("胥江风土人情信息");
			$this->data['heading_title'] ="胥江风土人情信息";
			foreach ($policeInfos as $policeInfo) {
				if ($policeInfo['pic_url'] && file_exists(DIR_IMAGE . $policeInfo['pic_url'])) {
					$image = $this->model_tool_image->resize($policeInfo['pic_url'], 120, 80);
				} else {
					$image = $this->model_tool_image->resize('no_image.jpg', 120, 80);
				}
				$this->data['policeInfos'][] = array(
					'image' =>$image,
					'href'=>$this->url->link('message/ethos/info', 'ethos_id='.$policeInfo['ethos_id'], 'SSL'),
					'title' =>$policeInfo['title'],
					'summary' =>$policeInfo['summary'],
				);
			}
			

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/message/ethos_all.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/message/ethos_all.tpl';
			} else {
				$this->template = 'default/template/message/ethos_all.tpl';
			}

			$this->children = array(
				'common/column_left',
				'common/column_right',
				'common/content_top',
				'common/content_bottom',
				'common/footer',
				'common/header'
			);

			$this->response->setOutput($this->render());
	}
	
	
	
	public function info() {  
		$this->language->load('message/ethos');

		$this->load->model('message/ethos');

		$this->data['breadcrumbs'] = array();

		$this->data['breadcrumbs'][] = array(
			'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home'),
			'separator' => false
		);

		if (isset($this->request->get['ethos_id'])) {
			$ethos_id = (int)$this->request->get['ethos_id'];
		} else {
			$ethos_id = 0;
		}

		$company_info = $this->model_message_ethos->getEthos($ethos_id);

		if ($company_info) {
			$this->document->setTitle($company_info['title']);

			$this->data['breadcrumbs'][] = array(
				'text'      => $company_info['title'],
				'href'      => $this->url->link('message/company', 'ethos_id=' .  $ethos_id),      		
				'separator' => $this->language->get('text_separator')
			);

			$this->data['heading_title'] = $company_info['title'];

			$this->data['button_continue'] = $this->language->get('button_continue');

			$this->data['description'] = html_entity_decode($company_info['description'], ENT_QUOTES, 'UTF-8');

			$this->data['continue'] = $this->url->link('common/home');

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/message/ethos.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/message/ethos.tpl';
			} else {
				$this->template = 'default/template/message/ethos.tpl';
			}

			$this->children = array(
				'common/column_left',
				'common/column_right',
				'common/content_top',
				'common/content_bottom',
				'common/footer',
				'common/header'
			);

			$this->response->setOutput($this->render());
		} else {
			$this->data['breadcrumbs'][] = array(
				'text'      => $this->language->get('text_error'),
				'href'      => $this->url->link('message/article', 'article_id=' . $article_id),
				'separator' => $this->language->get('text_separator')
			);

			$this->document->setTitle($this->language->get('text_error'));

			$this->data['heading_title'] = $this->language->get('text_error');

			$this->data['text_error'] = $this->language->get('text_error');

			$this->data['button_continue'] = $this->language->get('button_continue');

			$this->data['continue'] = $this->url->link('common/home');

			$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');

			if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
				$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
			} else {
				$this->template = 'default/template/error/not_found.tpl';
			}

			$this->children = array(
				'common/column_left',
				'common/column_right',
				'common/content_top',
				'common/content_bottom',
				'common/footer',
				'common/header'
			);

			$this->response->setOutput($this->render());
		}
	}

}
?>